'use strict';

var webpackConfig = require('./webpack.config.js');
var webpackDevConfig = require('./webpack.dev.config.js');

module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);
  grunt.initConfig({
    'webpack': {
      options: webpackConfig,
      dist: {
        cache: false
      }
    },

    'webpack-dev-server': {
      options: {
        hot: false,
        port: 8080,
        host: '0.0.0.0',
        historyApiFallback: true,
        webpack: webpackDevConfig,
        publicPath: '/js/',
        contentBase: './dist/'
      },

      start: {
        keepAlive: true
      }
    }
  });

  grunt.registerTask('web-dev', function (target) {
    return grunt.task.run(['webpack-dev-server']);
  });

  grunt.registerTask('web', function (target) {
    return grunt.task.run(['webpack']);
  });
};

/**
historyApiFallback: {
  rewrites: [
    { from: /^\/admin/, to: '/admin/index.html' }
  ]
},
**/
